package com.firebird.app.reader.pdf.activity

import android.app.Activity
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import com.firebird.app.reader.R

open class BaseActivity : Activity(), View.OnClickListener {
    protected var mContentView: View? = null
    private var mLinearLayout: LinearLayout? = null
    protected var mBackBtn: ImageView? = null
    override fun onCreate(savedInstanceState: Bundle) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_base)
        mLinearLayout = findViewById<View>(R.id.container) as LinearLayout
        mBackBtn = findViewById<View>(R.id.base_top_left_btn) as ImageView
        mBackBtn!!.setOnClickListener(this)
    }

    fun setContentLayout(layoutResId: Int) {
        val mInflater = getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
        mContentView = mInflater.inflate(layoutResId, null)
        val layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)
        mContentView?.setLayoutParams(layoutParams)
        if (null != mLinearLayout) {
            //mLinearLayout!!.addView(mContentView,layoutParams)
            mLinearLayout!!.addView(mContentView)
        }
    }

    override fun onClick(view: View) {
        when (view.id) {
            R.id.base_top_left_btn -> finish()
        }
    }
}